import javax.microedition.rms.*;
import java.util.*;
import java.io.*;

abstract public class BaseRMS {
  private RecordStore recordStore;

  public void open() throws Exception {
    try {
      recordStore = RecordStore.openRecordStore(getRMSName(),true);
    } catch (Exception e) {
      throw new Exception(getRMSName()+"::open::"+e);
    }
  }
  
  public String getRMSName() {
      return "";
  }

  public void close() throws Exception {
    if (recordStore != null) {
      try {
        recordStore.closeRecordStore();
      } catch(Exception e) {
      	throw new Exception(getRMSName()+"::close::"+e);
      }
    }
  }

  public RecordStore getRecordStore() {
    return this.recordStore;
  }
  
  public int getNumRecords() throws RecordStoreNotOpenException {
      return this.recordStore.getNumRecords();
  }

  abstract void loadData() throws Exception;
  abstract void createDefaultData() throws Exception;
  abstract void updateData() throws Exception;
}